package hu.genius.view.old;

import hu.genius.CoreApplication;
import hu.genius.R;
import hu.genius.model.BasketManager;
import hu.genius.model.DBUtil;
import hu.genius.model.entity.Product;
import hu.genius.view.utils.ViewUtils;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class Soups extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.d("zs", "create " + this.getClass().getName() + " product list.");

		super.onCreate(savedInstanceState);
		setContentView(R.layout.products);

		CoreApplication application = (CoreApplication) this.getApplication();
		BasketManager basketManager = application.getBasketManager();
		Log.d("zs", this.getClass().getName() + ": " + basketManager.toString());
		List<Product> products = DBUtil.listProductsByCategory(this, 4);

		TextView productsTextView = (TextView) findViewById(R.id.productsLabelTextView);
		productsTextView.setText(getText(R.string.products_label) + " - "
				+ getString(R.string.soups_text));

		ScrollView actionView = (ScrollView) findViewById(R.id.productsScrollView);
		
//		LinearLayout linearLayout = new LinearLayout(this);
//		Product product = products.get(0);
//		ImageView imageView = (ImageView) findViewById(R.id.productImageView);
//		imageView = ViewUtils.setupProductImageView(this, imageView, product);
//		linearLayout.addView(imageView);
//		
//		RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
//		buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
//		buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
//		
//		Button productSelectButton = new Button(this);
//		productSelectButton.setText(getText(R.string.product_select_button_label));
//		productSelectButton.setLayoutParams(buttonLayoutParams);
//		
//		RelativeLayout.LayoutParams productNameTextViewLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
//		productNameTextViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
//		productNameTextViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
//		
//		TextView productNameTextView = new TextView(this);
//		productNameTextView.setText(product.getName());
//		productNameTextView.setLayoutParams(productNameTextViewLayoutParams);
//		
//		RelativeLayout.LayoutParams productPriceTextViewLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
//		productPriceTextViewLayoutParams.addRule(RelativeLayout.ABOVE, R.id.productNameTextView);
//		productPriceTextViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
//		
//		TextView productPriceTextView = new TextView(this);
//		productPriceTextView.setText(product.getPrice() + " Ft");
//		productPriceTextView.setLayoutParams(productPriceTextViewLayoutParams);
//		
//		RelativeLayout relativeLayout = new RelativeLayout(this);
//		relativeLayout.addView(productSelectButton);
//		relativeLayout.addView(productNameTextView);
//		relativeLayout.addView(productPriceTextView);
//
//		actionView.addView(relativeLayout);
		 actionView.addView(ViewUtils.buildProductsView(this, products));
	}

//	@SuppressWarnings("unused")
//	private void buildProductListView(Context context, ScrollView scrollView,
//			List<Product> products) {
//		Product product = products.get(0);
//		ImageView imageView = (ImageView) findViewById(R.id.productImageView);
//		imageView = ViewUtils.setupProductImageView(context, imageView, product);
////		for (Product product : products) {
////			LinearLayout linearLayout = (LinearLayout) findViewById(R.layout.product_item_layout2);
////			ImageView imageView = (ImageView) linearLayout.findViewById(R.id.productImageView);
////			imageView.setImageBitmap(ViewUtils.loadImage(
////					linearLayout.getContext(), product.getId() + "s110c"
////							+ product.getPrice() + ".00i"));
////			imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewUtils
////					.getDpSize(linearLayout.getContext(), 110), ViewUtils
////					.getDpSize(linearLayout.getContext(), 110)));
////			scrollView.addView(linearLayout);
////		}
//	}
}